package com.nercel.dsj.gksales.util;

public enum SpikeResult {

	SUCCESS(0, "秒杀成功"),
	FAILNOTEXIST(1, "活动不存在"), 
	FAILNOTSTARTED(2, "活动未开始"),
	FAILSOLDOUT(3, "已售罄"),
	FAILENDED(4, "活动已结束"), 
	FAILOTHERS(99, "其他异常");

	private SpikeResult(Integer code, String msg) {
		this.code = code;
		this.msg = msg;
	}

	private Integer code;

	private String msg;

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public static String getMsgByCode(Integer code) {
		SpikeResult[] values = SpikeResult.values();
		for (SpikeResult sr : values) {
			if (sr.getCode().equals(code)) {
				return sr.getMsg();
			}
		}
		return null;
	}

	public static Integer getCodeByMsge(String msg) {
		SpikeResult[] values = SpikeResult.values();
		for (SpikeResult sr : values) {
			if (sr.getMsg().equals(msg)) {
				return sr.getCode();
			}
		}
		return null;
	}
}
